home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / amigaunits / hardblocks.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-22  |  11KB  |  252 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. unit hardblocks;
  18.  
  19. INTERFACE
  20.  
  21. uses exec;
  22.  
  23. {--------------------------------------------------------------------
  24.  *
  25.  *      This file describes blocks of data that exist on a hard disk
  26.  *      to describe that disk.  They are not generically accessable to
  27.  *      the user as they do not appear on any DOS drive.  The blocks
  28.  *      are tagged with a unique identifier, checksummed, and linked
  29.  *      together.  The root of these blocks is the RigidDiskBlock.
  30.  *
  31.  *      The RigidDiskBlock must exist on the disk within the first
  32.  *      RDB_LOCATION_LIMIT blocks.  This inhibits the use of the zero
  33.  *      cylinder in an AmigaDOS partition: although it is strictly
  34.  *      possible to store the RigidDiskBlock data in the reserved
  35.  *      area of a partition, this practice is discouraged since the
  36.  *      reserved blocks of a partition are overwritten by "Format",
  37.  *      "Install", "DiskCopy", etc.  The recommended disk layout,
  38.  *      then, is to use the first cylinder(s) to store all the drive
  39.  *      data specified by these blocks: i.e. partition descriptions,
  40.  *      file system load images, drive bad block maps, spare blocks,
  41.  *      etc.
  42.  *
  43.  *      Though only 512 byte blocks are currently supported by the
  44.  *      file system, this proposal tries to be forward-looking by
  45.  *      making the block size explicit, and by using only the first
  46.  *      256 bytes for all blocks but the LoadSeg data.
  47.  *
  48.  *------------------------------------------------------------------}
  49.  
  50. {
  51.  *  NOTE
  52.  *      optional block addresses below contain $ffffffff to indicate
  53.  *      a NULL address, as zero is a valid address
  54. }
  55.  
  56. type
  57.  
  58.     pRigidDiskBlock = ^tRigidDiskBlock;
  59.     tRigidDiskBlock = record
  60.         rdb_ID          : ULONG;      { 4 character identifier }
  61.         rdb_SummedLongs : ULONG;      { size of this checksummed structure }
  62.         rdb_ChkSum      : ULONG;      { block checksum (longword sum to zero) }
  63.         rdb_HostID      : ULONG;      { SCSI Target ID of host }
  64.         rdb_BlockBytes  : ULONG;      { size of disk blocks }
  65.         rdb_Flags       : ULONG;      { see below for defines }
  66.  
  67.     { block list heads }
  68.  
  69.         rdb_BadBlockList : ULONG;     { optional bad block list }
  70.         rdb_PartitionList : ULONG;    { optional first partition block }
  71.         rdb_FileSysHeaderList : ULONG; { optional file system header block }
  72.         rdb_DriveInit   : ULONG;      { optional drive-specific init code }
  73.  
  74.                                 { DriveInit(lun,rdb,ior): "C" stk & d0/a0/a1 }
  75.  
  76.         rdb_Reserved1   : Array [0..5] of ULONG; { set to $ffffffff }
  77.  
  78.     { physical drive characteristics }
  79.  
  80.         rdb_Cylinders   : ULONG;      { number of drive cylinders }
  81.         rdb_Sectors     : ULONG;      { sectors per track }
  82.         rdb_Heads       : ULONG;      { number of drive heads }
  83.         rdb_Interleave  : ULONG;      { interleave }
  84.         rdb_Park        : ULONG;      { landing zone cylinder }
  85.         rdb_Reserved2   : Array [0..2] of ULONG;
  86.         rdb_WritePreComp : ULONG;     { starting cylinder: write precompensation }
  87.         rdb_ReducedWrite : ULONG;     { starting cylinder: reduced write current }
  88.         rdb_StepRate    : ULONG;      { drive step rate }
  89.         rdb_Reserved3   : Array [0..4] of ULONG;
  90.  
  91.     { logical drive characteristics }
  92.  
  93.         rdb_RDBBlocksLo : ULONG;      { low block of range reserved for hardblocks }
  94.         rdb_RDBBlocksHi : ULONG;      { high block of range for these hardblocks }
  95.         rdb_LoCylinder  : ULONG;      { low cylinder of partitionable disk area }
  96.         rdb_HiCylinder  : ULONG;      { high cylinder of partitionable data area }
  97.         rdb_CylBlocks   : ULONG;      { number of blocks available per cylinder }
  98.         rdb_AutoParkSeconds : ULONG;  { zero for no auto park }
  99.         rdb_Reserved4   : Array [0..1] of ULONG;
  100.  
  101.     { drive identification }
  102.  
  103.         rdb_DiskVendor  : Array [0..7] of Char;
  104.         rdb_DiskProduct : Array [0..15] of Char;
  105.         rdb_DiskRevision : Array [0..3] of Char;
  106.         rdb_ControllerVendor : Array [0..7] of Char;
  107.         rdb_ControllerProduct : Array [0..15] of Char;
  108.         rdb_ControllerRevision : Array [0..3] of Char;
  109.         rdb_Reserved5   : Array [0..9] of ULONG;
  110.     end;
  111.  
  112. const
  113.     IDNAME_RIGIDDISK    = $5244534B;   { RDSK }
  114.  
  115.     RDB_LOCATION_LIMIT  = 16;
  116.  
  117.     RDBFB_LAST          = 0;    { no disks exist to be configured after }
  118.     RDBFF_LAST          = $01;  {   this one on this controller }
  119.     RDBFB_LASTLUN       = 1;    { no LUNs exist to be configured greater }
  120.     RDBFF_LASTLUN       = $02;  {   than this one at this SCSI Target ID }
  121.     RDBFB_LASTTID       = 2;    { no Target IDs exist to be configured }
  122.     RDBFF_LASTTID       = $04;  {   greater than this one on this SCSI bus }
  123.     RDBFB_NORESELECT    = 3;    { don't bother trying to perform reselection }
  124.     RDBFF_NORESELECT    = $08;  {   when talking to this drive }
  125.     RDBFB_DISKID        = 4;    { rdb_Disk... identification valid }
  126.     RDBFF_DISKID        = $10;
  127.     RDBFB_CTRLRID       = 5;    { rdb_Controller... identification valid }
  128.     RDBFF_CTRLRID       = $20;
  129.                                 { added 7/20/89 by commodore: }
  130.     RDBFB_SYNCH         = 6;    { drive supports scsi synchronous mode }
  131.     RDBFF_SYNCH         = $40;  { CAN BE DANGEROUS TO USE IF IT DOESN'T! }
  132.  
  133. {------------------------------------------------------------------}
  134.  
  135. type
  136.  
  137.     pBadBlockEntry = ^tBadBlockEntry;
  138.     tBadBlockEntry = record
  139.         bbe_BadBlock    : ULONG;      { block number of bad block }
  140.         bbe_GoodBlock   : ULONG;      { block number of replacement block }
  141.     end;
  142.  
  143.     pBadBlockBlock = ^tBadBlockBlock;
  144.     tBadBlockBlock = record
  145.         bbb_ID          : ULONG;      { 4 character identifier }
  146.         bbb_SummedLongs : ULONG;      { size of this checksummed structure }
  147.         bbb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
  148.         bbb_HostID      : ULONG;      { SCSI Target ID of host }
  149.         bbb_Next        : ULONG;      { block number of the next BadBlockBlock }
  150.         bbb_Reserved    : ULONG;
  151.         bbb_BlockPairs  : Array [0..60] of tBadBlockEntry; { bad block entry pairs }
  152.     { note [61] assumes 512 byte blocks }
  153.     end;
  154.  
  155. const
  156.  
  157.     IDNAME_BADBLOCK     = $42414442;   { BADB }
  158.  
  159. {------------------------------------------------------------------}
  160.  
  161. type
  162.  
  163.     pPartitionBlock = ^tPartitionBlock;
  164.     tPartitionBlock = record
  165.         pb_ID           : ULONG;      { 4 character identifier }
  166.         pb_SummedLongs  : ULONG;      { size of this checksummed structure }
  167.         pb_ChkSum       : Longint;      { block checksum (longword sum to zero) }
  168.         pb_HostID       : ULONG;      { SCSI Target ID of host }
  169.         pb_Next         : ULONG;      { block number of the next PartitionBlock }
  170.         pb_Flags        : ULONG;      { see below for defines }
  171.         pb_Reserved1    : Array [0..1] of ULONG;
  172.         pb_DevFlags     : ULONG;      { preferred flags for OpenDevice }
  173.         pb_DriveName    : Array [0..31] of Char; { preferred DOS device name: BSTR form }
  174.                                         { (not used if this name is in use) }
  175.         pb_Reserved2    : Array [0..14] of ULONG; { filler to 32 longwords }
  176.         pb_Environment  : Array [0..16] of ULONG; { environment vector for this partition }
  177.         pb_EReserved    : Array [0..14] of ULONG; { reserved for future environment vector }
  178.     end;
  179.  
  180. const
  181.  
  182.     IDNAME_PARTITION    = $50415254;    { PART }
  183.  
  184.     PBFB_BOOTABLE       = 0;    { this partition is intended to be bootable }
  185.     PBFF_BOOTABLE       = 1;    {   (expected directories and files exist) }
  186.     PBFB_NOMOUNT        = 1;    { do not mount this partition (e.g. manually }
  187.     PBFF_NOMOUNT        = 2;    {   mounted, but space reserved here) }
  188.  
  189. {------------------------------------------------------------------}
  190.  
  191. type
  192.  
  193.     pFileSysHeaderBlock = ^tFileSysHeaderBlock;
  194.     tFileSysHeaderBlock = record
  195.         fhb_ID          : ULONG;      { 4 character identifier }
  196.         fhb_SummedLongs : ULONG;      { size of this checksummed structure }
  197.         fhb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
  198.         fhb_HostID      : ULONG;      { SCSI Target ID of host }
  199.         fhb_Next        : ULONG;      { block number of next FileSysHeaderBlock }
  200.         fhb_Flags       : ULONG;      { see below for defines }
  201.         fhb_Reserved1   : Array [0..1] of ULONG;
  202.         fhb_DosType     : ULONG;      { file system description: match this with }
  203.                                 { partition environment's DE_DOSTYPE entry }
  204.         fhb_Version     : ULONG;      { release version of this code }
  205.         fhb_PatchFlags  : ULONG;      { bits set for those of the following that }
  206.                                 {   need to be substituted into a standard }
  207.                                 {   device node for this file system: e.g. }
  208.                                 {   0x180 to substitute SegList & GlobalVec }
  209.         fhb_Type        : ULONG;      { device node type: zero }
  210.         fhb_Task        : ULONG;      { standard dos "task" field: zero }
  211.         fhb_Lock        : ULONG;      { not used for devices: zero }
  212.         fhb_Handler     : ULONG;      { filename to loadseg: zero placeholder }
  213.         fhb_StackSize   : ULONG;      { stacksize to use when starting task }
  214.         fhb_Priority    : Longint;      { task priority when starting task }
  215.         fhb_Startup     : Longint;      { startup msg: zero placeholder }
  216.         fhb_SegListBlocks : Longint;    { first of linked list of LoadSegBlocks: }
  217.                                 {   note that this entry requires some }
  218.                                 {   processing before substitution }
  219.         fhb_GlobalVec   : Longint;      { BCPL global vector when starting task }
  220.         fhb_Reserved2   : Array [0..22] of ULONG; { (those reserved by PatchFlags) }
  221.         fhb_Reserved3   : Array [0..20] of ULONG;
  222.     end;
  223.  
  224. const
  225.  
  226.     IDNAME_FILESYSHEADER        = $46534844;    { FSHD }
  227.  
  228. {------------------------------------------------------------------}
  229.  
  230. Type
  231.  
  232.     pLoadSegBlock = ^tLoadSegBlock;
  233.     tLoadSegBlock = record
  234.         lsb_ID          : ULONG;      { 4 character identifier }
  235.         lsb_SummedLongs : ULONG;      { size of this checksummed structure }
  236.         lsb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
  237.         lsb_HostID      : ULONG;      { SCSI Target ID of host }
  238.         lsb_Next        : ULONG;      { block number of the next LoadSegBlock }
  239.         lsb_LoadData    : Array [0..122] of ULONG;    { data for "loadseg" }
  240.     { note [123] assumes 512 byte blocks }
  241.     end;
  242.  
  243. const
  244.  
  245.     IDNAME_LOADSEG      = $4C534547;    { LSEG }
  246.  
  247. IMPLEMENTATION
  248.  
  249. end.
  250.  
  251.  
  252.